<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Fasilitas extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	function __construct()
	{
		parent::__construct();
		$this->load->model('ktig');
		$this->load->library('form_validation');
	}
	public function index()
	{
		$this->load->helper('url');
		$this->load->view('header');
		$this->load->view('v_fasilitas');
	}
	public function input_form()
	{
		$this->load->helper('url');
		/*
		$tanggal_input = $this->input->post('tanggal_jam');
		$tanggal = date("Y-m-d", strtotime($tanggal_input));
		$jam = date("H:i:s", strtotime($tanggal_input));
		*/
		$tanggal_input = $this->input->post('tanggal');
		$jam_input = $this->input->post('jam');
		
		$tanggal = date("Y-m-d", strtotime($tanggal_input));
		$jam = date("H:i:s", strtotime($jam_input));
		
		if($this->input->post('bahan')=="ya") { $bahan=1; } else { $bahan=null; }
		if($this->input->post('put')=="ya") { $put=1; } else { $put=null; }
		if($this->input->post('kun')=="ya") { $kun=1; } else { $kun=null; }
		if($this->input->post('lih')=="ya") { $lih=1; } else { $lih=null; }
		if($this->input->post('tand')=="ya") { $tand=1; } else { $tand=null; }
		if($this->input->post('chy')=="ya") { $chy=1; } else { $chy=null; }
		if($this->input->post('ang')=="ya") { $ang=1; } else { $ang=null; }
		
		if($this->input->post('lok')=="ya") { $lok=1; } else { $lok=null; }
		if($this->input->post('tek')=="ya") { $tek=1; } else { $tek=null; }
		if($this->input->post('seg')=="ya") { $seg=1; } else { $seg=null; }
		if($this->input->post('uli')=="ya") { $uli=1; } else { $uli=null; }
		if($this->input->post('sumb')=="ya") { $sumb=1; } else { $sumb=null; }
		if($this->input->post('tab')=="ya") { $tab=1; } else { $tab=null; }
		
		if($this->input->post('exi')=="ya") { $exi=1; } else { $exi=null; }
		if($this->input->post('hlg')=="ya") { $hlg=1; } else { $hlg=null; }
		if($this->input->post('eva')=="ya") { $eva=1; } else { $eva=null; }
		if($this->input->post('papa')=="ya") { $papa=1; } else { $papa=null; }
		if($this->input->post('ppn')=="ya") { $ppn=1; } else { $ppn=null; }
		if($this->input->post('asm')=="ya") { $asm=1; } else { $asm=null; }
		if($this->input->post('bly')=="ya") { $bly=1; } else { $bly=null; }
		
		if($this->input->post('sft')=="ya") { $sft=1; } else { $sft=null; }
		if($this->input->post('lang')=="ya") { $lang=1; } else { $lang=null; }
		if($this->input->post('shw')=="ya") { $shw=1; } else { $shw=null; }
		
		$data=array(
			'JENIS_FORM'=>1,
			'LOKASI'=>$this->input->post('lokasi'),
			'BAGIAN'=>$this->input->post('bagian'),
			'DEPARTEMEN'=>$this->input->post('departemen'),
			'TANGGAL'=>$tanggal,
			'JAM'=>$jam,
			'K1'=>$bahan,
			'KK1'=>$this->input->post('ket1'),
			'K2'=>$put,
			'KK2'=>$this->input->post('ket2'),
			'K3'=>$kun,
			'KK3'=>$this->input->post('ket3'),
			'K4'=>$lih,
			'KK4'=>$this->input->post('ket4'),
			'K5'=>$tand,
			'KK5'=>$this->input->post('ket5'),
			'K6'=>$chy,
			'KK6'=>$this->input->post('ket6'),
			'K7'=>$ang,
			'KK7'=>$this->input->post('ket7'),
			
			'A1'=>$lok,
			'KA1'=>$this->input->post('ket8'),
			'A2'=>$tek,
			'KA2'=>$this->input->post('ket9'),
			'A3'=>$seg,
			'KA3'=>$this->input->post('ket10'),
			'A4'=>$uli,
			'KA4'=>$this->input->post('ket11'),
			'A5'=>$sumb,
			'KA5'=>$this->input->post('ket12'),
			'A6'=>$tab,
			'KA6'=>$this->input->post('ket13'),
			
			'P1'=>$exi,
			'PK1'=>$this->input->post('ket14'),
			'P2'=>$hlg,
			'PK2'=>$this->input->post('ket15'),
			'P3'=>$eva,
			'PK3'=>$this->input->post('ket16'),
			'P4'=>$papa,
			'PK4'=>$this->input->post('ket17'),
			'P5'=>$ppn,
			'PK5'=>$this->input->post('ket18'),
			'P6'=>$asm,
			'PK6'=>$this->input->post('ket19'),
			'P7'=>$bly,
			'PK7'=>$this->input->post('ket20'),
			
			'E1'=>$sft,
			'PE1'=>$this->input->post('ket21'),
			'E2'=>$lang,
			'PE2'=>$this->input->post('ket22'),
			'E3'=>$shw,
			'PE3'=>$this->input->post('ket23'),
			
			'ANGGOTA'=>$this->input->post('nama1'),
			'ANGGOTA2'=>$this->input->post('nama2'),
			'PENGAWAS'=>$this->input->post('pengawas'),
			'STATUS'=>$this->input->post('sekretaris')
		  );
		$this->db->insert('checklist_fasilitas',$data);
		
		redirect('fasilitas/lihat');
	}
	public function lihat()
	{
		$this->load->helper('url');
		$this->load->view('header');
		
		$data['datalist'] = $this->ktig->list_fasilitas();
		
		$this->load->view('v_fasilitas_lihat',$data);
	}
	public function hapus($id)
	{
		$this->load->helper('url');
		$this->ktig->hapus_fasilitas($id);
		redirect('fasilitas/lihat');
	}
	public function ubah($id)
	{
		$this->load->helper('url');
		$this->load->view('header');
		if($this->input->post('submit'))
		{
			$this->ktig->update_fasilitas($id);
			redirect('fasilitas/lihat');
		}
		$data['hasil']=$this->ktig->data_fasilitas($id);
		$this->load->view('v_fasilitas_ubah',$data);
	}
	public function detail($id)
	{
		$this->load->helper('url');
		$this->load->view('header');
		if($this->input->post('submit'))
		{
			redirect('fasilitas/lihat');
		}
		
		$data['hasil']=$this->ktig->data_fasilitas($id);
		$this->load->view('v_fasilitas_detail',$data);
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */